﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Handrise.CDCable.Mobile.Business;
using Handrise.CDCable.Mobile.GISControl;

namespace Handrise.CDCable.Mobile.UI
{
    public partial class FrmEquipGIS :FrmBase
    {
        private double scalenum; //缩放比例

        private string parentForm;
        private Device device;
        public FrmEquipGIS()
        {
            InitializeComponent();
            ttlbrhead.Text = ResourceImage.设备台账;
            ilstbcup.Images.Add(ResourceImage.空白);
            ilstbcup.Images.Add(ResourceImage.空白);
            ilstbcup.Images.Add(ResourceImage.返回01);
            ilstdown.Images.Add(ResourceImage.空白);
            ilstdown.Images.Add(ResourceImage.空白);
            ilstdown.Images.Add(ResourceImage.返回02);
            UGISmap.CacheStoragePath = AppLogic.GetLocalPath() + @"\mapcache";
            ibzoomout.UpImage = ResourceImage.缩小可点击;
            ibzoomout.DownImage = ResourceImage.缩小点击;
            ibzoomout.DisableImage = ResourceImage.缩小不可点击;
            Ibzoomin.UpImage = ResourceImage.放大可点击;
            Ibzoomin.DownImage = ResourceImage.放大点击;
            Ibzoomin.DisableImage = ResourceImage.放大不可点击;
            UGISmap.Getcatchmap();
            scalenum = UGISmap.Scale / 10;
            UGISmap.Scale = UGISmap.Scale / 10;

        }

        private void bcxunjian_OnButtonClick(object sender, int buttonIndex)
        {

        }

        private void bcxunjian_OnButtonClick_1(object sender, int buttonIndex)
        {
          FormManage.GotoNext("FrmDeviceDetail", null,null, true);
 
        }

        private void ibzoomout_Click(object sender, EventArgs e)
        {

        }

        private void Ibzoomin_Click(object sender, EventArgs e)
        {

        }

        private void Ibzoomin_Click_1(object sender, EventArgs e)
        {
         
            UGISmap.Scale = UGISmap.Scale - UGISmap.Scale / 5;
            UGISmap.showlayer();
        }

        private void ibzoomout_Click_1(object sender, EventArgs e)
        {
            UGISmap.Scale = UGISmap.Scale + UGISmap.Scale / 5;
            UGISmap.showlayer();
        
        }
        private void LoadData()
        {
            parentForm = (string)Parameter[0];
            device = (Device)Parameter[1];
            tbdevicename.Text = device.Name;


        }

        private void FrmEquipGIS_Load(object sender, EventArgs e)
        {
            LoadData();
            Getequippoint();
        }
        /// <summary>
        /// 获取轨迹点
        /// </summary>
        private void Getequippoint()
        {
            // GetuserGPSTrace
            DeviceGPSService gpsts = new DeviceGPSService();

            DeviceGPS DeviceGPS = gpsts.GetDeviceGPSByDeviceCode(device.Code);
            if (DeviceGPS != null)
            {

                PDGPS PDGPS = new PDGPS();
                PDGPS.DeviceGPSID = DeviceGPS.DeviceCode;
                PDGPS.DeviceCode = DeviceGPS.DeviceCode;
                PDGPS.DeviceType = device.DeviceType;
                PDGPS.LocalGPSInfo = DeviceGPS.LocalGPSInfo;
                PDGPS.GPSInfo =DeviceGPS.GPSInfo;
                PDGPS.Devicename =device.Name;
                UGISmap.ListPoint.Add(PDGPS);
                UGISmap.ShowDeviceName = true;
                UGISmap.changepoint();
                String[] sArray = DeviceGPS.GPSInfo.Split(';');
                String[] sArray1 = sArray[0].Split(',');
                UGISmap.atpoint(Convert.ToDouble(sArray1[0]), Convert.ToDouble(sArray1[1]));
               
            }
          
        }

        private void FrmEquipGIS_Closed(object sender, EventArgs e)
        {
            UGISmap.closecatch();
        }
    }
}